import com.qian.api.ddj.util.SignUtils;
import com.yaowk.api.utils.HttpUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Test;

import java.util.Map;
import java.util.TreeMap;

public class XJWG {

    private String KEY = "670362e5ac601925cbb55efcaf0ac6f5";
    private String USERID = "187651";

    @Test
    public void pay() {
        Map<String, String> map = new TreeMap<>();
        map.put("userid", USERID);
        map.put("amount", "10");
        map.put("bankCode", "3001");
        map.put("defaultbank", "1002");
        map.put("returnUrl", "http://extman.kefupay.cn/newWechats/test111.action");
        /**参与验签的字段*/
        String sign = SignUtils.params(map);
        System.out.println("计算签名的报文为：" + sign);
        sign = DigestUtils.md5Hex(sign + KEY);
        map.put("orderCode", "xj_gateway");
        map.put("sign", sign);
        map.put("pay_number", String.valueOf(System.currentTimeMillis()));
        map.put("notify_url", "http://extman.kefupay.cn/newWechats/test111.action");
        String baowen = HttpUtils.formatData(map);
        System.out.println("上送的报文为：" + baowen);
        String sr = HttpUtils.post("http://extman.kefupay.cn/pay/pay_mobile.action", baowen);
        System.out.println(sr);
    }
}
